/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GestionPtosFecha.java
 *
 * Created on 29/09/2009, 19:28:15
 */

package tpgrandt.UI;

import javax.swing.DefaultComboBoxModel;
import javax.swing.table.TableColumn;
import tpgrandt.control.GestionPuntajes;
import tpgrandt.varios.Partido;

/**
 *
 * @author k3nsou
 */
public class PuntajesDeLaFecha extends javax.swing.JInternalFrame {

    private GestionPuntajes gestion;
    private String fechas[];
    private Partido partidos[];

    /** Creates new form GestionPtosFecha */
    public PuntajesDeLaFecha(GestionPuntajes gestion) {
        super("Gestionar puntajes de la fecha", false, true, false, false);
        initComponents();

        this.gestion = gestion;

        int aux[] = gestion.listarFechas();
        fechas = new String[aux.length];
        for(int i = 0; i < aux.length; i++)
            fechas[i] = new Integer(aux[i]).toString();
        jComboBox2.setModel(new DefaultComboBoxModel(fechas));

        int fecha = Integer.parseInt(jComboBox2.getSelectedItem().toString().trim());
        partidos = gestion.listarPartidos(fecha);

        TableColumn column = null;
        column = jTable1.getColumnModel().getColumn(0);
        column.setPreferredWidth(150);
        column = jTable1.getColumnModel().getColumn(1);
        column.setPreferredWidth(80);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, "VER"},
                {null, null, null, "VER "},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"},
                {null, null, null, "VER"}
            },
            new String [] {
                "Equipo local", "Equipo visitante", "Estado", "Detalles"
            }
        ));
        jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jTable1.setMinimumSize(new java.awt.Dimension(30, 10));
        jScrollPane1.setViewportView(jTable1);
        TableColumn tc = jTable1.getColumn("Equipo local");
        tc.setPreferredWidth(140);
        tc = jTable1.getColumn("Equipo visitante");
        tc.setPreferredWidth(140);
        tc = jTable1.getColumn("Estado");
        tc.setPreferredWidth(60);
        tc = jTable1.getColumn("Detalles");
        tc.setPreferredWidth(60);

        jButton1.setText("Cerrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel16.setText("Fecha:");

        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(399, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(195, Short.MAX_VALUE)
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(180, 180, 180))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        int fecha = Integer.parseInt(jComboBox2.getSelectedItem().toString().trim());
        partidos = gestion.listarPartidos(fecha);
}//GEN-LAST:event_jComboBox2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables

    private PuntajesDelPartido cdu10b;
}
